using System;
using System.Windows;
using System.Windows.Media.Animation;
namespace Microsoft.Phone.Controls
{
	internal static class PhysicsConstants
	{
		internal static double GetStopTime(Point initialVelocity)
		{
			double num = Math.Min(Math.Sqrt(initialVelocity.get_X() * initialVelocity.get_X() + initialVelocity.get_Y() * initialVelocity.get_Y()), MotionParameters.MaximumSpeed);
			if (MotionParameters.ParkingSpeed >= num)
			{
				return 0.0;
			}
			return Math.Log(MotionParameters.ParkingSpeed / num) / Math.Log(MotionParameters.Friction);
		}
		internal static Point GetStopPoint(Point initialVelocity)
		{
			double num = Math.Sqrt(initialVelocity.get_X() * initialVelocity.get_X() + initialVelocity.get_Y() * initialVelocity.get_Y());
			Point initialVelocity2 = initialVelocity;
			if (num > MotionParameters.MaximumSpeed && num > 0.0)
			{
				initialVelocity2.set_X(initialVelocity2.get_X() * (MotionParameters.MaximumSpeed / num));
				initialVelocity2.set_Y(initialVelocity2.get_Y() * (MotionParameters.MaximumSpeed / num));
			}
			double num2 = (Math.Pow(MotionParameters.Friction, PhysicsConstants.GetStopTime(initialVelocity2)) - 1.0) / Math.Log(MotionParameters.Friction);
			return new Point(initialVelocity2.get_X() * num2, initialVelocity2.get_Y() * num2);
		}
		internal static IEasingFunction GetEasingFunction(double stopTime)
		{
			ExponentialEase exponentialEase = new ExponentialEase();
			exponentialEase.set_Exponent(stopTime * Math.Log(MotionParameters.Friction));
			exponentialEase.set_EasingMode(1);
			return exponentialEase;
		}
	}
}
